import { reqGetCategoryList, reqGetBannerList, reqGetFloorList } from "@/api";

const state = {
  categoryList: [],
  bannerList: [],
  floorList: [],
};
const actions = {
  //    categoryList(){
  //     reqGetCategoryList().then((res)=>{
  //            console.log(res.data)
  //        },(err)=>{
  //            console.log(err)
  //        })
  //     }
  //获取三级联动数据
  async getCategoryList({ commit }) {
    let result = await reqGetCategoryList();
    console.log("三级联动", result);
    if (result.code === 200) {
      commit("GETCATEGORYLIST", result.data);
    }
  },
  // 获取轮播图数据
  async getBannerList({ commit }) {
    let result = await reqGetBannerList();
    console.log("轮播图bannerlist", result);
    if (result.code == 200) {
      commit("GETBANNERLIST", result.data);
    }
  },
  // 获取floor数据
  async getFloorList({ commit }) {
    let result = await reqGetFloorList();
    console.log("floor", result);
    if (result.code === 200) {
      commit("GETFLOORLIST", result.data);
    }
  },
};
const mutations = {
  GETCATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList;
  },
  GETBANNERLIST(state, bannerList) {
    state.bannerList = bannerList;
  },
  GETFLOORLIST(state, floorList) {
    state.floorList = floorList;
  },
};
const getters = {};
export default {
  state,
  actions,
  mutations,
  getters,
};
